<?php

namespace Modules\Goods\Database\Seeders;

use Illuminate\Database\Seeder;
use Illuminate\Database\Eloquent\Model;
use Modules\Goods\Entities\Category;

class CategoriesTableSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        
        // 宠物用品
        $data = [
            '饮料酒水'  => ['碳酸饮料', '奶制品', '功能饮料', '矿泉水', '冲调', '酒'],
            '休闲食品'  => ['方便速食', '饼干糕点', '零食'],
            '卫生用品'  => ['纸品湿巾', '卫生巾', '家洗用品', '毛巾浴巾', '洗发护理', '口腔护理'],
            '厨房用品'  => ['调料', '米面粮油', '干货', '厨房清洁', '厨房工具'],
            '文具办公'  => ['文件整理', '笔类', '本类', '手工用品'],
            '家用电器'  => ['电池', '插电板', '数码配件', '厨房电器', '其他'],
            '日用百货'  => ['一次性用品', '雨具', '宠物食品'],
            '母婴用品'  => ['婴童用品', '尿不湿', '奶粉', '妈妈用品',],
            '果蔬蛋类'  => ['菜谱套餐', '叶果类', '根茎类', '葱姜蒜', '加工品', '蛋品', '水果', '肉类家禽', '海鲜鱼类'],
            '冷冻保鲜'  => ['冰激凌', '冷冻食品', '肉类', '海鲜'],
            '桶装水'  => ['矿泉水', '纯净水'],
        ];


        foreach ($data as $k => $v) {
            $id = Category::insertGetId([
                'title'  => $k,
                'parent_id'  => 0,
            ]);

            foreach ($v as $item) {
                Category::create([
                    'title'  => $item,
                    'parent_id'  => $id,
                ]);
            }
        }

    }
}
